/**
 * @param {string} word
 * @return {number}
 */
 var minTimeToType = function(word) {
  let ans = word.length
  const sDif = Math.abs(word.charCodeAt(0) -'a'.charCodeAt(0))
  ans += Math.min(sDif, 26-sDif)
  for(let i = 1; i<word.length; i++){
    const dif = Math.abs(word.charCodeAt(i) -word.charCodeAt(i-1))
    ans += Math.min(dif, 26-dif)
  }
  return ans
};